package com.allwees.bs.module.scm.rest;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.allwees.bs.core.modelbase.vo.R;
import com.allwees.bs.module.core.dynamic.annotation.DynamicInject;
import com.allwees.bs.module.core.rest.BoCrudApi;
import com.allwees.bs.module.scm.entity.ScmAllocateOrderSku;
import com.allwees.bs.module.scm.req.AllocateOrderSkuJoinPickReq;
import com.allwees.bs.module.scm.req.AllocateOrderSkuMarkHaveReq;
import com.allwees.bs.module.scm.req.AllocateOrderSkuMarkSelloutReq;
import com.allwees.bs.module.scm.req.query.ScmAllocateOrderSkuQueryReq;
import com.allwees.bs.module.scm.service.ScmAllocateOrderSkuService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/backstage/api/scm/allocate_order")
public class ScmAllocateOrderSkuApi extends BoCrudApi<ScmAllocateOrderSku, ScmAllocateOrderSkuService> {

    @DynamicInject(key = "orderItemUuid")
    @GetMapping("/page")
    public R page(Page<ScmAllocateOrderSku> page, ScmAllocateOrderSkuQueryReq req) {
        return super.page(page, req);
    }

    @PostMapping("/mark_sellout")
    public R markSellout(@RequestBody AllocateOrderSkuMarkSelloutReq req) {
        boService.markSellout(req);
        return R.ok();
    }

    @PostMapping("/mark_have")
    public R markHave(@RequestBody AllocateOrderSkuMarkHaveReq req) {
        boService.markHave(req);
        return R.ok();
    }

    @PostMapping("/join_pick")
    public R joinPick(@RequestBody AllocateOrderSkuJoinPickReq req) {
        boService.joinPick(req);
        return R.ok();
    }

    @PostMapping("/export")
    public R export(@RequestBody ScmAllocateOrderSkuQueryReq req) {
        boService.export(req);
        return R.ok();
    }

    @GetMapping("/{uuid}/refund_reason")
    public R refundReason(@PathVariable String uuid) {
        boService.refundReason(uuid);
        return R.ok();
    }
}
